$().ready(function() {
	validateRule();
});

$.validator.setDefaults({
	submitHandler : function() {
		update();
	}
});
function update() {
	var formData = new FormData($('#signupForm')[0]);  
	
	$.ajax({
		cache : true,
		type : "POST",
		url : "/system/operator/update",
		data : formData,// 你的formid
		processData: false, 
		contentType : false,
		async : false,
		error : function(request) {
			parent.layer.alert("Connection error");
		},
		success : function(data) {
			if (data.code == 0) {
				parent.layer.msg("操作成功");
				parent.reLoad();
				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
				parent.layer.close(index);

			} else {
				parent.layer.alert(data.msg)
			}

		}
	});

}
function validateRule() {
	var icon = "<i class='fa fa-times-circle'></i> ";
	$("#signupForm").validate({
		rules : {
			operatorName : {
				required : true
			},
			operatorFans : {
				required : true
			},
			operatorCycle : {
				required : true
			},
			operatorMoney : {
				required : true
			},
			operatorPhone : {
				required : true
			},
			operatorDetails : {
				required : true
			},
			file : {
				required : true
			},
			status : {
				required : true
			}
		},
		messages : {
			operatorName : {
				required : icon + "请输入名字"
			},
			operatorFans : {
				required : icon + "请输入运营商粉丝"
			},
			operatorCycle : {
				required : icon + "请输入运营周期"
			},
			operatorMoney : {
				required : icon + "请输入运营商报价"
			},
			operatorPhone : {
				required : icon + "请输入运营商电话"
			},
			operatorDetails : {
				required : icon + "请输入运营商详情"
			},
			file : {
				required : icon + "请选择运营商详情图片"
			},
			status : {
				required : icon + "请输入审核状态(0是未审核，1是审核通过，3是审核未通过)"
			}
		}
	})
}